import request from '@/utils/request'

export function getCartList() {
  return request({
    url: '/cart/list',
    method: 'get'
  })
}

export function getPurchaseProductList(data) {
  return request({
    url: '/orderQg/cartList',
    method: 'post',
    data
  })
}

export function getCartGoodsCount() {
  return request({
    url: '/cart/goodsCount',
    method: 'get'
  })
}

export function addCart(data) {
  return request({
    url: '/cart',
    method: 'post',
    data
  })
}

export function addDefaultGoodsProduct(data) {
  return request({
    url: '/cart/addDefaultGoodsProduct',
    method: 'post',
    data
  })
}

export function updateCart(data) {
  return request({
    url: '/cart',
    method: 'put',
    data
  })
}

export function changeNumber(cartId, number) {
  return request({
    url: `/cart/changeNum/${cartId}/${number}`,
    method: 'post'
  })
}

export function addNumber(cartId, number) {
  return request({
    url: `/cart/addNum/${cartId}/${number}`,
    method: 'post'
  })
}

export function minusNumber(cartId, number) {
  return request({
    url: `/cart/minusNum/${cartId}/${number}`,
    method: 'post'
  })
}

export function deleteCart(cartId) {
  return request({
    url: '/cart/' + cartId,
    method: 'delete'
  })
}

export function getCheckedGoods() {
  return request({
    url: '/cart/getCheckedGoods',
    method: 'get'
  })
}

/**
 * 加入購物車
 * @returns {AxiosPromise}
 */
export function addShopCart(data) {
  return request({
    url: '/orderQg/addCartCg',
    method: 'post',
    data
  })
}

/**
 * 检查按钮状态和去上架
 * @returns {AxiosPromise}
 */
export function checkAddReq(data) {
  return request({
    url: `/orderQg/cgShelves`,
    method: 'post',
    data
  })
}
/**
 * 检查按钮状态和去上架
 * @returns {AxiosPromise}
 */
export function cgShelvesVerify(data) {
  return request({
    url: `/orderQg/cgShelvesVerify`,
    method: 'post',
    data
  })
}

export function settleCart(data) {
  return request({
    url: '/orderQg/completeCgOrder',
    method: 'post',
    data
  })
}

export function getRepositoryData(data) {
  return request({
    url: '/orderQg/repositoryData',
    method: 'get',
    params: data
  })
}
// 获取买/卖单历史记录
export function getHistoryRepositoryData(data) {
  return request({
    url: '/user/getTodaySalesOrder',
    method: 'get',
    params: data
  })
}

export function updateWarehouseStatus(data) {
  return request({
    url: `/orderQg/saleStatusUpdate`,
    method: 'post',
    data
  })
}
export function userSelfQrCode(data) {
  return request({
    url: `/orderQg/userSelfQrCode`,
    method: 'get',
    params: data
  })
}
export function getCargoPrice(data) {
  return request({
    url: `/orderQg/caculateFee`,
    method: 'get',
    params: data
  })
}

export function updatePayment(data) {
  return request({
    url: `/orderQg/geiAuditInfo`,
    method: 'get',
    params: data
  })
}
export function updatePayAuditRefuse(data) {
  return request({
    url: `/orderQg/payAuditRefuse`,
    method: 'get',
    params: data
  })
}

export function deletePurchaseCart(data) {
  return request({
    url: '/orderQg/removeCartCg',
    method: 'post',
    data: data
  })
}

export function getGoodsPro(data) {
  return request({
    url: '/orderQg/cgTakeDeliveryGoods',
    method: 'post',
    data
  })
}
// 获取调单状态
export function canIDel() {
  return request({
    url: '/home/getIsAdjustmentSwitch',
    method: 'get'
  })
}


// 获取是否可以加入购物车
export function verifyAddCartCg() {
  return request({
    url: '/orderQg/verifyAddCartCg',
    method: 'get'
  })
}